package org.jeecg.modules.demo.crm.util;

import org.jeecg.modules.demo.crm.dto.PendingDTO;

import java.util.*;

public class IndexUtils {

    private static List<Map<String, String>> iconColors = new ArrayList<>();
    static {
        // 创建并添加每个 Map 对象
        iconColors.add(createMap("ion:home-outline", "#1fdaca"));
        iconColors.add(createMap("ion:notifications", "#13b0ff"));
        iconColors.add(createMap("ion:grid-outline", "#bf0c2c"));
        iconColors.add(createMap("ion:layers-outline", "#e18525"));
        iconColors.add(createMap("ion:settings-outline", "#3fb27f"));
        iconColors.add(createMap("ion:person-stalker", "#b27315"));
    }

    public static List<PendingDTO> setIconAndColor(List<PendingDTO> list){
        for (PendingDTO pendingDTO : list) {
            // 随机获取一个 Map 对象
            Random random = new Random();
            int randomIndex = random.nextInt(iconColors.size());
            Map<String, String> randomItem = iconColors.get(randomIndex);
            pendingDTO.setIcon(randomItem.get("icon"));
            pendingDTO.setColor(randomItem.get("color"));
        }
        return list;

    }


    // 辅助方法：创建一个包含 icon 和 color 的 Map
    private static Map<String, String> createMap(String icon, String color) {
        Map<String, String> map = new HashMap<>();
        map.put("icon", icon);
        map.put("color", color);
        return map;
    }

}
